package com.dzl.movie;

import com.dzl.base.controller.BaseController;
import com.dzl.config.exception.CommonException;
import com.dzl.moive.pojo.WelfareMovieInfo;
import com.dzl.moive.pojo.query.WelfareMovieCinemaQuery;
import com.dzl.moive.pojo.vo.WelfareMoviePageBannerVo;
import com.dzl.moive.service.WelfareMovieInfoService;
import com.dzl.util.EmptyUtils;
import com.dzl.util.JsonResult;
import com.dzl.util.RedisUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * 电影基础信息(welfare_movie_info)表控制层
 * @author liuguanjun
 * @date 2021-11-02 16:04:29
 */
@RestController
@RequestMapping("/welfareMovieInfo")
public class WelfareMovieInfoController extends BaseController {

    @Autowired
    private WelfareMovieInfoService service;

    /**
     * 获取热映电影或待映电影
     * @param type 类型：1热映 2待映
     * @author liuguanjun
     * @date 2021-11-02 16:12:50
     **/
    @GetMapping(value = "getMovieInfoList")
    public JsonResult<List<WelfareMovieInfo>> getMovieInfoList(String citycode, Integer type) {
        if(EmptyUtils.isEmpty(citycode)){
            return JsonResult.failWithMsg("缺少参数:城市编码[citycode]");
        }
        if(EmptyUtils.isEmpty(type)){
            return JsonResult.failWithMsg("缺少参数:电影类型[type]");
        }
        return JsonResult.success(service.getMovieInfoList(citycode,type));
    }

    /**
     * 获取电影票详情
     * @param query citycode 城市编码等字段
     * @author liuguanjun
     * @date 2021-11-04 10:16:50
     **/
    @GetMapping(value = "getMovieInfoDetail")
    public JsonResult<WelfareMovieInfo> getMovieInfoDetail(WelfareMovieCinemaQuery query) {
        if(EmptyUtils.isEmpty(query.getCitycode())){
            return JsonResult.failWithMsg("缺少参数:城市编码[citycode]");
        }
        if(EmptyUtils.isEmpty(query.getLat())){
            throw new CommonException("缺少参数:当前地址纬度[lat]");
        }
        if(EmptyUtils.isEmpty(query.getLon())){
            throw new CommonException("缺少参数:当前地址经度[lon]");
        }
        if(EmptyUtils.isEmpty(query.getMovieid())){
            throw new CommonException("缺少参数:电影id[movieid]");
        }
        return JsonResult.success(service.getMovieInfoDetail(query));
    }

    /**
     * 获取电影板块首页banner图
     * @author liuguanjun
     * @date 2021-11-10 10:00:50
     **/
    @GetMapping(value = "getMoviePageBannerList")
    public JsonResult<Map> getMoviePageBannerList() {
        return JsonResult.success(service.getMoviePageBannerList());
    }

/*
    *//**
     * 获取电影详情
     * @param id 电影id
     * @author liuguanjun
     * @date 2021-11-02 16:12:50
     **//*
    @GetMapping(value = "getMovieInfoDetail")
    public JsonResult<WelfareMovieInfo> getMovieInfoDetail(Integer id) {
        if(EmptyUtils.isEmpty(id)){
            return JsonResult.failWithMsg("缺少参数:电影id[id]");
        }
        return JsonResult.success(service.getMovieInfoDetail(id));
    }

    *//**
     * 获取电影购票详情获取日期格式,包括今天以及往后7天
     * @author liuguanjun
     * @date 2021-11-03 15:19:50
     **//*
    @GetMapping(value = "getMovieDateList")
    public JsonResult<List<WelfareMovieDateVo>> getMovieDateList() {
        return JsonResult.success(service.getMovieDateList());
    }*/

}
